package cn.yunhe.service.impl;

import cn.yunhe.dao.IUserDao;
import cn.yunhe.entity.User;
import cn.yunhe.service.IuserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service
public class UserService implements IuserService {
    @Resource
    private IUserDao userDao;


    @Override
    public Page getLikeUsers(Map<String, Object> cond) {
        Page page = new Page();
        page.setTotal(userDao.getCount(cond));
        int pageSize = Integer.parseInt(String.valueOf(cond.get("pageSize")));
        page.setPageSize(pageSize);
        int pageNum = Integer.parseInt(String.valueOf(cond.get("pageNum")));
        page.setPageNum(pageNum);
        page.setPageNum((int)(page.getTotal()/pageSize+(page.getTotal()%pageSize==0?0:1)));
        page = PageHelper.startPage(pageNum,pageSize);
        List<User> list = userDao.getLikeUsers(cond);
        return page;
    }
}
